//页面初始加载
efform_onload = function() {
	var fdPlanStatus = decodeURI($("#fdPlanStatus").val());
	//隐藏/显示从表按钮
	if(fdPlanStatus != '草拟')
		hideAndShowSubButtons(false);
	else
		hideAndShowSubButtons(true);
};
/********************************************************************************
 ***********************************从表操作************************************* 
 ********************************************************************************/
//从表新增
button_insertdetail_onclick = function (){
	if (isSelected("ef_grid_d") == 0)return; 
	efgrid.submitForm( "ef_grid_d", "ZM","ZMCP41","insert",true);
};
//从表修改
button_updatedetail_onclick = function (){ 
	if (isSelected("ef_grid_d") == 0)return; 
	efgrid.submitForm( "ef_grid_d", "ZM","ZMCP41","update",true);
};
//从表删除
button_deletedetail_onclick = function (){
	var grid=isSelected("ef_grid_d");
	if (grid == 0)return;  
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r){
			efgrid.submitForm( "ef_grid_d", "ZM","ZMCP41","delete",true);
		}
	});
}
/********************************************************************************
 ***********************************公共方法**************************************** 
 ********************************************************************************/
//根据数据状态显示或掩藏按钮函数
var hideAndShowSubButtons=function(status)
{
	if(!status)
	{
		efbutton.setButtonStatus("insertdetail", false);
		efbutton.setButtonStatus("updatedetail", false);
		efbutton.setButtonStatus("deletedetail", false);
	}else
	{
		efbutton.setButtonStatus("insertdetail", true);
		efbutton.setButtonStatus("updatedetail", true);
		efbutton.setButtonStatus("deletedetail", true);
	}
}

//新增、修改、删除后的执行方法
efgrid_onAjaxSubmitSuccess = function(gridId, service_name, method_name, eiInfo) {
	if(gridId == "ef_grid_d") {
		if (eiInfo.status != -1) {
			var grid = efgrid.getGridObject("ef_grid_d");
			grid.refresh( eiInfo );
		}
		else
		{
			submitCallBackEiMsg = eiInfo.msg;
		}
	}
};